package com.taoding.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 用户session对象
 *
 * @author wuwentan
 * @date 2018/8/17
 */

public class UserSession implements Serializable {

    private static ThreadLocal<UserSession> userSessionHolder = new ThreadLocal<UserSession>();

    /**
     * sessionId
     */
    private String sessionId;

    /**
     * 用户实体的id
     */
    private String userId;

    /**
     * 用户实体的用户名
     */
    private String username;

    /**
     * 用户的姓名
     */
    private String name;

    /**
     * 用户的角色id
     */
    private String roleId;

    /**
     * 身份标识
     */
    private String flag;

    /**
     * 是否管理员标识
     */
    private String isAdmin;

    /**
     * 用户所属平台标识
     */
    private String corpId;

    /**
     * 微信唯一标识id
     */
    private String openId;

    /**
     * 所属部门
     */
    private String deptId;

    /**
     * 用户的角色标识
     */
    private List<String> roleCodeList = new ArrayList<String>();

    /**
     * 获取用户session
     *
     * @return
     */
    public static UserSession getUserSession() {
        UserSession userSession = userSessionHolder.get();
        return userSession == null ? new UserSession() : userSession;
    }

    public static void setUserSession(UserSession userSession){
        userSessionHolder.set(userSession);
    }

    public static void remove(){
        userSessionHolder.remove();
    }

    public static ThreadLocal<UserSession> getUserSessionHolder() {
        return userSessionHolder;
    }

    public static void setUserSessionHolder(ThreadLocal<UserSession> userSessionHolder) {
        UserSession.userSessionHolder = userSessionHolder;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRoleId() {
        return roleId;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public String getIsAdmin() {
        return isAdmin;
    }

    public void setIsAdmin(String isAdmin) {
        this.isAdmin = isAdmin;
    }

    public String getCorpId() {
        return corpId;
    }

    public void setCorpId(String corpId) {
        this.corpId = corpId;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getDeptId() {
        return deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }

    public List<String> getRoleCodeList() {
        return roleCodeList;
    }

    public void setRoleCodeList(List<String> roleCodeList) {
        this.roleCodeList = roleCodeList;
    }
}
